FIND_PATH(FREEIMAGE_INCLUDE_DIR FreeImage.h)
FIND_LIBRARY(FREEIMAGE_LIBRARY FreeImage)
OPTION(FREEIMAGE_USE_STATIC "Link with static version of FreeImage" OFF)

IF(FREEIMAGE_INCLUDE_DIR AND FREEIMAGE_LIBRARY)
    SET(EXTERNAL_INCLUDE_DIR ${FREEIMAGE_INCLUDE_DIR})
    SET(EXTERNAL_LIBRARIES ${FREEIMAGE_LIBRARY})
    IF(FREEIMAGE_USE_STATIC)
        ADD_DEFINITIONS(-DFREEIMAGE_LIB)
    ENDIF(FREEIMAGE_USE_STATIC)
    
    SET(LIBRARY_NAME osgdb_freeimage)
    SET(LIBRARY_FILES ReaderWriterFreeImage.cpp)
    START_LIBRARY()
ENDIF(FREEIMAGE_INCLUDE_DIR AND FREEIMAGE_LIBRARY)
